package com.zqxq.lottery.entity.o2o.order;

import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.bo.order.TradeInfoBO;
import com.zqxq.lottery.entity.po.order.TradeInfoPO;
import com.zqxq.lottery.entity.vo.order.TradeInfoVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 说    明：   交易回调信息
 * 创 建 人：	一刀·胡
 * 创建时间：	2018/3/22 12:04
 * 修 改 人：
 * 修改日期：
 **/
public class TradeInfoO2O {

    public static TradeInfoVO toVO(TradeInfoPO po) {
        if (po == null) {
            return null;
        }
        TradeInfoVO tradeInfoVO = new TradeInfoVO();
        tradeInfoVO.setId(DispatcherUtils.parseString(po.getId()));
        tradeInfoVO.setUserId(DispatcherUtils.parseString(po.getUser_id()));
        tradeInfoVO.setTradeNo(po.getTrade_no());
        tradeInfoVO.setTradeWay(DispatcherUtils.parseString(po.getTrade_way()));
        tradeInfoVO.setTradeType(DispatcherUtils.parseString(po.getTrade_type()));
        tradeInfoVO.setOrderId(DispatcherUtils.parseString(po.getOrder_id()));
        tradeInfoVO.setData(po.getData());
        tradeInfoVO.setOrderId(DispatcherUtils.parseString(po.getOrder_id()));
        tradeInfoVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        return tradeInfoVO;
    }

    public static TradeInfoPO toPO(TradeInfoVO vo) {
        if (vo == null) {
            return null;
        }
        TradeInfoPO tradeInfoPO = new TradeInfoPO();
        tradeInfoPO.setId(DispatcherUtils.parseLong(vo.getId()));
        tradeInfoPO.setUser_id(DispatcherUtils.parseLong(vo.getUserId()));
        tradeInfoPO.setTrade_no(vo.getTradeNo());
        tradeInfoPO.setTrade_way(DispatcherUtils.parseInteger(vo.getTradeWay()));
        tradeInfoPO.setTrade_type(DispatcherUtils.parseInteger(vo.getTradeType()));
        tradeInfoPO.setOrder_id(DispatcherUtils.parseLong(vo.getOrderId()));
        tradeInfoPO.setData(vo.getData());
        tradeInfoPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        return tradeInfoPO;
    }

    public static TradeInfoPO toPO(TradeInfoBO bo) {
        if (bo == null) {
            return null;
        }
        TradeInfoPO tradeInfoPO = new TradeInfoPO();
        tradeInfoPO.setUser_id(bo.getUserId());
        tradeInfoPO.setTrade_no(bo.getTradeNo());
        tradeInfoPO.setTrade_way(bo.getTradeWay());
        tradeInfoPO.setTrade_type(bo.getTradeType());
        tradeInfoPO.setOrder_id(bo.getOrderId());
        tradeInfoPO.setResult(bo.getResult());
        tradeInfoPO.setData(bo.getData());
        return tradeInfoPO;
    }

    public static List<TradeInfoVO> toVOList(List<TradeInfoPO> list){
        List<TradeInfoVO> result = new ArrayList<>();
        if(list != null && list.size() > 0){
            for(TradeInfoPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }

}
